package com.jiangxiaofei.citycloud.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jiangxiaofei.citycloud.R;
import com.jiangxiaofei.citycloud.bean.BannerBean;
import com.zhouwei.mzbanner.holder.MZHolderCreator;
import com.zhouwei.mzbanner.holder.MZViewHolder;

/**
 * @author: JiangXFei
 * @date: 2017/11/17 0017
 * @content:
 */

public class BannerViewHolder implements MZHolderCreator {
    Context mContext;

    public BannerViewHolder(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public MZViewHolder createViewHolder() {
        return new MZViewHolder() {

            private ImageView imageView;

            @Override
            public View createView(Context context) {
                imageView = (ImageView) LayoutInflater.from(context).inflate(R.layout.view_image_banner, null);
                return imageView;
            }

            @Override
            public void onBind(Context context, int i, Object o) {
                BannerBean bannerBean = (BannerBean) o;
                Glide.with(mContext).load(bannerBean.getImgurl()).into(imageView);
                imageView.invalidate();
            }
        };

    }
}
